<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>x86汇编指令脚本虚拟机</title>
    <meta name="description" content="简介这是一个可以直接解释执行从ida pro里面提取出来的x86汇编代码的虚拟机。非常精简，整体架构上不能跟那些成熟的虚拟机相比，主要目标是够用、能用、轻量就行，如果觉得代码架构设计的不是很好的话，也不用过于吐槽哈。。虽然我还有写过两个比较成熟的虚拟机项目（jvm和avm），虽然架构上比这个更完善，更容易扩展，功...">

    
    <meta name="keywords" content="xmake,x86,汇编,虚拟机,windows,跨平台,idapro,逆向分析,tboox" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/2016/07/26/x86-script-instruction-virtual-machine/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" post>
    <div class="left">
        <h1>x86汇编指令脚本虚拟机</h1>
        <div class="label">

            <div class="label-card">
                <i class="fa fa-calendar"></i>2016-07-26
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
                
            </div>

            <div class="label-card">
            


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#vm86" title="Category: vm86" rel="category">vm86</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


            </div>

            <div class="label-card">
            
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <!--a href="/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a-->
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <!--a href="/tag/#x86" title="Tag: x86" rel="tag">x86</a-->
        <a href="/cn/tag/#x86" title="Tag: x86" rel="tag">x86</a>&nbsp;
    
        <!--a href="/tag/#%E6%B1%87%E7%BC%96" title="Tag: 汇编" rel="tag">汇编</a-->
        <a href="/cn/tag/#汇编" title="Tag: 汇编" rel="tag">汇编</a>&nbsp;
    
        <!--a href="/tag/#%E8%99%9A%E6%8B%9F%E6%9C%BA" title="Tag: 虚拟机" rel="tag">虚拟机</a-->
        <a href="/cn/tag/#虚拟机" title="Tag: 虚拟机" rel="tag">虚拟机</a>&nbsp;
    
        <!--a href="/tag/#windows" title="Tag: windows" rel="tag">windows</a-->
        <a href="/cn/tag/#windows" title="Tag: windows" rel="tag">windows</a>&nbsp;
    
        <!--a href="/tag/#%E8%B7%A8%E5%B9%B3%E5%8F%B0" title="Tag: 跨平台" rel="tag">跨平台</a-->
        <a href="/cn/tag/#跨平台" title="Tag: 跨平台" rel="tag">跨平台</a>&nbsp;
    
        <!--a href="/tag/#idapro" title="Tag: idapro" rel="tag">idapro</a-->
        <a href="/cn/tag/#idapro" title="Tag: idapro" rel="tag">idapro</a>&nbsp;
    
        <!--a href="/tag/#%E9%80%86%E5%90%91%E5%88%86%E6%9E%90" title="Tag: 逆向分析" rel="tag">逆向分析</a-->
        <a href="/cn/tag/#逆向分析" title="Tag: 逆向分析" rel="tag">逆向分析</a>
    
  

</span>

            </div>

        </div>
        <hr>
        <article itemscope itemtype="http://schema.org/BlogPosting">
        <h2 id="简介">简介</h2>

<p>这是一个可以直接解释执行从ida pro里面提取出来的x86汇编代码的虚拟机。</p>

<p>非常精简，整体架构上不能跟那些成熟的虚拟机相比，主要目标是够用、能用、轻量就行，如果觉得代码架构设计的不是很好的话，也不用过于吐槽哈。。</p>

<p>虽然我还有写过两个比较成熟的虚拟机项目（jvm和avm），虽然架构上比这个更完善，更容易扩展，功能也更强大</p>

<p>但是毕竟是给公司写的，没法拿出来分享。。</p>

<h2 id="背景">背景</h2>

<p>先说说，为什么要写这个东西。。</p>

<p>之前有段时间，我在用ida逆向分析某些程序的算法，并且要把它提取出来将其跨平台运行，这个时候我首先考虑到是ida的F5插件</p>

<p>毕竟这个可以直接反成c/c++代码，还是很强大的，基本上98%的x86汇编代码，我在通过f5还原成c/c++代码后，都能正常运行。</p>

<p>原本我以为可以万事大吉了，不过就在当我沾沾自喜的时候，发现其中某个汇编函数的c代码，死活就是运行不正常，输出结果不对。</p>

<p>而且那个函数偏偏代码量出奇的大，光c代码就有上万行，而且里面还对数据结构和明文都做了变换和加密，要是慢慢调试的话，得痛苦死。。哎。。</p>

<p>没办法，只好另想出路，既然ida还原c有时候不一定完全准确，但是其汇编代码的准确度还是可以保证的，并且从ida中提取的汇编代码
基本上，不用怎么改，就能编译通过，因此，我先验证了下直接编译汇编代码，运行看看结果对不对。。</p>

<p>结果跟我想的一样，是ok的。。那么问题来了。。</p>

<p>既然汇编运行结果正常，那怎么把它整成跨平台运行呢，直接从编译后x86的指令集进行模拟？工作量有点大，得不偿失。。</p>

<p>有没有取巧些办法呢？当然有，那就是直接解析和运行源码级的x86汇编代码，相当于写个轻量级的精简版x86的脚本虚拟机，来把它运行起来。。</p>

<p>听上去，貌似更麻烦了，其实由于这里只要能够跑通部分需要的汇编指令就行了，因此写个精简版的还是很方便，不需要多少工作量</p>

<p>我前前后后，也就花了一个礼拜就搞定了，非常精简，当然也不完善（也没必要哈，不能跟那些大部头相比）</p>

<p>我的目标就是够用就行，因此我写的差不多厚，就尝试去加载之前有问题的汇编代码，如果发现有指令没实现，那就去实现它，直到跑通为主。。</p>

<p>最后测试结果：</p>

<p>可以正常跑通那个十几万行的汇编代码，并且在arm下运行的性能还算ok，至少满足我的个人需求了。。: )</p>

<h2 id="特性">特性</h2>

<ul>
  <li>跨平台运行支持，可以在windows、linux、macosx以及android, ios上运行x86的汇编代码。。</li>
  <li>支持常用x86汇编指令（例如，逻辑操作，跳转，循环，调用，压栈等指令）</li>
  <li>支持函数间跳转，以及第三方api调用</li>
  <li>支持参数传入，以及运行结束后，返回值的获取</li>
  <li>虚拟机的运行粒度为单个函数，函数间的跳转可以通过多个虚拟机实例来完成（轻量的，性能影响不大）</li>
  <li>支持线程安全</li>
  <li>暂时不支持arm64，只能在32位下运行（有兴趣的同学可以自行修改）</li>
</ul>

<h2 id="例子">例子</h2>

<p>我们先从ida中提取一段汇编代码，这段汇编主要是<code class="highlighter-rouge">printf</code>库函数打印外部传入的数值</p>

<div class="highlighter-rouge"><pre class="highlight"><code>sub_hello	proc near 
arg_0		= dword	ptr  8 
.data 
        format db \"hello: %x\", 0ah, 0dh, 0 
 
off_5A74B0	dd offset loc_6B2B50	; DATA XREF: sub_589100+1832
		dd offset loc_58A945	; jump table for switch	statement 
 
.code 
        ; hi
        push	ebp ;hello 
		mov	ebp, esp 
 
    loc_6B2B50:				; CODE XREF: sub_6B2B40+8
        push    eax 
		mov	eax, [ebp+arg_0] 
        push eax 
        mov eax, offset format 
        push eax 
        call printf 
        add esp, 4 
        pop eax 
        
        mov ecx, 1
        jmp ds:off_5A74B0[ecx*4]
 
loc_58A945:
        push    eax 
		mov	eax, [ebp+arg_0] 
        push eax 
        mov eax, offset format 
        push eax 
        call printf 
        add esp, 4 
        pop eax 
        
  end:
        mov	esp, ebp 
		pop	ebp 
        retn 
sub_hello    endp 
</code></pre>
</div>

<p>如果用c来调用的话，就是</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="n">sub_hello</span><span class="p">(</span><span class="mi">31415926</span><span class="p">);</span>
</code></pre>
</div>

<p>输出结果：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>hello: 31415926
hello: 31415926
</code></pre>
</div>

<p>接下来我们把这段汇编直接放到我们的虚拟机里面执行：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code><span class="k">static</span> <span class="n">tb_void_t</span> <span class="nf">vm86_demo_proc_exec_hello</span><span class="p">(</span><span class="n">tb_uint32_t</span> <span class="n">value</span><span class="p">)</span>
<span class="p">{</span>
    <span class="c1">// 上述汇编代码的字符串表示
</span>    <span class="k">static</span> <span class="n">tb_char_t</span> <span class="k">const</span> <span class="n">s_code_sub_hello</span><span class="p">[]</span> <span class="o">=</span> 
    <span class="p">{</span>
<span class="s">"sub_hello	proc near </span><span class="se">\n</span><span class="s">\
arg_0		= dword	ptr  8 </span><span class="se">\n</span><span class="s">\
.data </span><span class="se">\n</span><span class="s">\
        format db </span><span class="se">\"</span><span class="s">hello: %x</span><span class="se">\"</span><span class="s">, 0ah, 0dh, 0 </span><span class="se">\n</span><span class="s">\
 </span><span class="se">\n</span><span class="s">\
off_5A74B0	dd offset loc_6B2B50	; DATA XREF: sub_589100+1832 </span><span class="se">\n</span><span class="s">\
		dd offset loc_58A945	; jump table for switch	statement </span><span class="se">\n</span><span class="s">\
 </span><span class="se">\n</span><span class="s">\
.code </span><span class="se">\n</span><span class="s">\
        ; hi</span><span class="se">\n</span><span class="s">\
        push	ebp ;hello </span><span class="se">\n</span><span class="s">\
		mov	ebp, esp </span><span class="se">\n</span><span class="s">\
 </span><span class="se">\n</span><span class="s">\
    loc_6B2B50:				; CODE XREF: sub_6B2B40+8</span><span class="se">\n</span><span class="s">\
        push    eax </span><span class="se">\n</span><span class="s">\
		mov	eax, [ebp+arg_0] </span><span class="se">\n</span><span class="s">\
        push eax </span><span class="se">\n</span><span class="s">\
        mov eax, offset format </span><span class="se">\n</span><span class="s">\
        push eax </span><span class="se">\n</span><span class="s">\
        call printf </span><span class="se">\n</span><span class="s">\
        add esp, 4 </span><span class="se">\n</span><span class="s">\
        pop eax </span><span class="se">\n</span><span class="s">\
        </span><span class="se">\n</span><span class="s">\
        mov ecx, 1</span><span class="se">\n</span><span class="s">\
        jmp ds:off_5A74B0[ecx*4]</span><span class="se">\n</span><span class="s">\
 </span><span class="se">\n</span><span class="s">\
loc_58A945:</span><span class="se">\n</span><span class="s">\
        push    eax </span><span class="se">\n</span><span class="s">\
		mov	eax, [ebp+arg_0] </span><span class="se">\n</span><span class="s">\
        push eax </span><span class="se">\n</span><span class="s">\
        mov eax, offset format </span><span class="se">\n</span><span class="s">\
        push eax </span><span class="se">\n</span><span class="s">\
        call printf </span><span class="se">\n</span><span class="s">\
        add esp, 4 </span><span class="se">\n</span><span class="s">\
        pop eax </span><span class="se">\n</span><span class="s">\
        </span><span class="se">\n</span><span class="s">\
  end:</span><span class="se">\n</span><span class="s">\
        mov	esp, ebp </span><span class="se">\n</span><span class="s">\
		pop	ebp </span><span class="se">\n</span><span class="s">\
        retn </span><span class="se">\n</span><span class="s">\
sub_hello    endp </span><span class="se">\n</span><span class="s">\
    "</span>
    <span class="p">};</span>

    <span class="c1">// 定义一个虚拟机
</span>    <span class="n">vm86_machine_ref_t</span> <span class="n">machine</span> <span class="o">=</span> <span class="n">vm86_machine</span><span class="p">();</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">machine</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// 锁定虚拟机，保证线程安全（这个根据需要，可选）
</span>        <span class="n">tb_spinlock_ref_t</span> <span class="n">lock</span> <span class="o">=</span> <span class="n">vm86_machine_lock</span><span class="p">(</span><span class="n">machine</span><span class="p">);</span>
        <span class="n">tb_spinlock_enter</span><span class="p">(</span><span class="n">lock</span><span class="p">);</span>

        <span class="c1">// 获取虚拟机的堆栈
</span>        <span class="n">vm86_stack_ref_t</span> <span class="n">stack</span> <span class="o">=</span> <span class="n">vm86_machine_stack</span><span class="p">(</span><span class="n">machine</span><span class="p">);</span>

        <span class="c1">// 编译上面的汇编代码，并生成一个过程对象的引用
</span>        <span class="n">vm86_proc_ref_t</span> <span class="n">proc</span> <span class="o">=</span> <span class="n">vm86_text_compile</span><span class="p">(</span><span class="n">vm86_machine_text</span><span class="p">(</span><span class="n">machine</span><span class="p">),</span> <span class="n">s_code_sub_hello</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">s_code_sub_hello</span><span class="p">));</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">proc</span><span class="p">)</span>
        <span class="p">{</span>
            <span class="c1">// 添加汇编里面需要调用到的外部库函数
</span>            <span class="n">vm86_machine_function_set</span><span class="p">(</span><span class="n">machine</span><span class="p">,</span> <span class="s">"printf"</span><span class="p">,</span> <span class="n">vm86_demo_proc_func_printf</span><span class="p">);</span>

            <span class="c1">// 初始化调用参数
</span>            <span class="n">vm86_stack_push</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">value</span><span class="p">);</span>

            <span class="c1">// 执行这个汇编代码
</span>            <span class="n">vm86_proc_done</span><span class="p">(</span><span class="n">proc</span><span class="p">);</span>

            <span class="c1">// 恢复堆栈，获取返回值（这里是void的，传null就行了）
</span>            <span class="n">vm86_stack_pop</span><span class="p">(</span><span class="n">stack</span><span class="p">,</span> <span class="n">tb_null</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// 解锁虚拟机
</span>        <span class="n">tb_spinlock_leave</span><span class="p">(</span><span class="n">lock</span><span class="p">);</span>
    <span class="p">}</span> 
<span class="p">}</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span><span class="o">**</span> <span class="n">argv</span><span class="p">)</span>
<span class="p">{</span>
    <span class="c1">// 执行这个汇编函数：sub_hello(0x31415926)
</span>    <span class="n">vm86_demo_proc_exec_hello</span><span class="p">(</span><span class="mh">0x31415926</span><span class="p">);</span>    
<span class="p">}</span>
</code></pre>
</div>

<p>如果ok，那么输出结果当然也是：</p>

<div class="highlighter-rouge"><pre class="highlight"><code>hello: 31415926
hello: 31415926
</code></pre>
</div>

<h2 id="源码">源码</h2>

<ul>
  <li><a href="https://github.com/waruqi/vm86">Github</a></li>
  <li><a href="/cn/project/">更多项目</a></li>
</ul>

<h2 id="编译">编译</h2>

<p>需要先安装<a href="http://www.xmake.io/cn">xmake</a></p>

<h3 id="在-macosx-上编译">在 macosx 上编译</h3>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>sudo brew install xmake
<span class="gp">$ </span>xmake f -a i386
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h3 id="在-linux-上编译">在 linux 上编译</h3>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>git clone https://github.com/waruqi/xmake.git
<span class="gp">$ </span><span class="nb">cd </span>xmake
<span class="gp">$ </span>sudo ./install
<span class="err">$</span>
<span class="gp">$ </span><span class="nb">cd </span>vm86
<span class="gp">$ </span>xmake f -a i386
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h3 id="在-windows-上编译">在 windows 上编译</h3>

<p>下载 https://github.com/waruqi/xmake/archive/master.zip</p>

<p>解压运行里面的 install.bat 安装xmake后进行编译：</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake
</code></pre>
</div>

<h3 id="编译android版本">编译android版本</h3>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span><span class="nb">cd </span>vm86
<span class="gp">$ </span>xmake f -p android --ndk<span class="o">=</span>/xxx/ndk
<span class="gp">$ </span>xmake
</code></pre>
</div>

<h2 id="运行">运行</h2>

<p>运行测试程序：</p>

<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>xmake r demo
</code></pre>
</div>

<h2 id="后话">后话</h2>

<p>最后，在项目的idc目录下，有两个脚本工具：<code class="highlighter-rouge">export_function.idc</code> 和 <code class="highlighter-rouge">export_data.idc</code> 可以用来辅助我们从ida中导出指定的汇编函数和数据</p>


        </article>
        <hr>

        <!-- baidu ads -->
        

        <!-- reward -->
        <div style="text-align: center;">
            <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
              <span>赏</span>
            </button>
            <div id="QR" style="display: none;">
                <div id="wechat" style="display: inline-block">
                  <img id="wechat_qr" src="/static/img/weixin.png" alt="WeChat Pay"/>
                  <p>微信打赏</p>
                </div>
                <div id="alipay" style="display: inline-block">
                  <img id="alipay_qr" src="/static/img/alipay.png" alt="Alipay"/>
                  <p>支付宝打赏</p>
                </div>
            </div>
        </div>

        
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
                    
                    <h2 id="english">English</h2>
                    <ul>
                    
                    <li class="relatedPost">
                        <a href="/2016/07/26/x86-script-instruction-virtual-machine/">The x86 Script Instruction Virtual Machine
                        
                        </a>
                    </li>
                    
                    
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
            
            
                
            
        
            
        
        
            </ul>
        

        
        
            
        
            
            
            
                
                    
                        
                        <h2 id="similar_posts">相关文章</h2>
                        <ul>
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
            
        
            
            
            
                
                    
                        
                        <li class="relatedPost">
                            <a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持
                            
                            </a>
                        </li>
                        
                        
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            
            
        
        
            </ul>
        

        <div class="post-recent">
    <div class="pre">

        

        

        
        
        

        

        

        
        
        <p><strong>上一篇</strong> <a href="/cn/2016/07/25/support-debugger-on-windows/">在windows下支持调试运行</a></p>
        
    </div>

    <div class="nex">

        

        

        
        
        

        

        

        
        
        <p><strong>下一篇</strong> <a href="/cn/2016/07/28/hnr-split-image/">手写数字识别系统之图像分割</a></p>
        
    </div>
</div>


        <h2 id="comments">评论</h2>
        






<div id="gitalk-container"></div>
<link rel="stylesheet" href="/css/gitalk.css">
<script src="/js/gitalk.min.js"></script>

<script>
const gitalk = new Gitalk({
  clientID: '73946dc1d9e2276ad0da',
  clientSecret: '12a3cb94361ba3ebc6ecb68cf80d592bfaa8106d',
  repo: 'tboox.github.io',
  owner: 'waruqi',
  admin: ['waruqi'],
  id: location.pathname,       
  language: 'zh-CN',
  distractionFreeMode: false  
})

gitalk.render('gitalk-container')
</script>





    </div>
    <button class="anchor"><i class="fa fa-anchor"></i></button>
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <!-- Content -->
            <div class="side content">
                <div>
                    内容
                </div>
                <ul id="content-side" class="content-ul">
                    <li><a href="#english">English</a></li>
                    <li><a href="#similar_posts">相关文章</a></li>
                    <li><a href="#comments">评论</a></li>
                </ul>
            </div>


            <!-- baidu ads -->
            
            
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    链接
                </div>
                <ul class="content-ul">
                  <li><a href="http://github.com/waruqi/tbox">tbox</a></li>
                  <li><a href="http://www.xmake.io">xmake</a></li>
                  <li><a href="https://github.com/waruqi">github</a></li>
                </ul>
            </div> 

            <!-- xmake courses -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193">
                </a>
            </div>

            <!-- qqgroup -->
            <br>
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    技术交流群（QQ）
                </div>
                <img src="/static/img/qqgroup.png" alt="qqgroup" width="256" height="284">
            </div> 

            <!-- google ads -->
            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>
<script>
/**
 * target _blank
 */
(function() {
    var aTags = document.querySelectorAll('article a:not([id])')
    for (var i = 0; i < aTags.length; i++) {
        aTags[i].setAttribute('target', '_blank')
    }
}());
</script>
<script src="/js/pageContent.js " charset="utf-8"></script>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
